import { mergeBms } from '@/api/resource'
import { apiGet, apiPost } from '@/utils/axios'
const systemId = process.env.VUE_APP_BMS_SYSTEM_ID || 9999

export default {
  // 获取用户菜单
  getUserMenu: () => apiGet(mergeBms('user/menu'), { systemId: systemId }, { loadingLoader: 'login' }),
  // 获取用户权限
  getUserPermissions: () => apiGet(mergeBms('user/permissions'), { systemId: systemId }),
  // 登录
  login: (params) => apiPost(mergeBms('oauth/token'), params, { loadingLoader: 'login' }),
  // 钉钉扫码登录鉴权
  dingtalkAuth: (params) => apiGet(mergeBms(`dingtalk/users/scan?systemId=${systemId}`), params, { loadingLoader: 'login' }),
  // 钉钉扫码登录
  dingtalkToken: (params) => apiPost(mergeBms(`oauth/token/dingtalk?useSso=true&systemId=${systemId}`), params, { loadingLoader: 'login' }),
  // 获取用户按钮权限
  getUserButton: () => apiGet(mergeBms('user/permissions'), { systemId: systemId }),
  // 获取用户的区域分支树
  getUserAreaBranchTree: () => apiGet(mergeBms('user/getVisibleAreaBranchTree'), { includeHeadOrg: true }, { noLoading: true }),
  // 修改密码
  modifyPsw: (params) => apiPost(mergeBms('oauth/user/password/modify'), params),
  // 获取当前登录用户所有分支列表信息
  getUserBelongBranches: () => apiGet(mergeBms('user/branches/list')),
  // 切换分支
  switchBranch: (hrOrgId) => apiPost(`${mergeBms('oauth/branches')}/${hrOrgId}?systemId=${systemId}`),
  // 获取组织机构树
  getOrgTree: (hrOrgId) => apiGet(`${mergeBms('org/getOrgTree')}`),
  // 获取加密登录密码用的公钥
  getPublicKey: () => apiGet(`${mergeBms('oauth/pubkey')}`),
  // 登出
  logout: () => apiPost(`${mergeBms('oauth/invalid')}`)
}
